
def dicRead(input_files):
	"""
	Given a dictionary input file, read the dictionary data structure 
	as a list of coefficients as shown in the instructions.
	"""
	lines=open(input_files).readlines()
	lines=[line.rstrip().split() for line in lines if line.strip()]

	for line in lines:
		for i in range(len(line)):
			#print line[i]
			line[i]=float(line[i])

	#begin sorting basic and non-basic variables in ascending order.

	#sorting basic variables
	dic_sorted=[lines[0]]
	dic_sorted.append(sorted(lines[1]))
	b0_sortedIndex=sorted(range(len(lines[1])), key=lambda k: lines[1][k])
	b0_sorted=[lines[3][idx] for idx in b0_sortedIndex]
	#dic_sorted.append(b0_sorted)
	#print b0_sortedIndex,b0_sorted

	#sorting non-basic variables
	dic_sorted.append(sorted(lines[2]))
	nonBasicCoeIndex=sorted(range(len(lines[2])), key=lambda k: lines[2][k])

	dic_sorted.append(b0_sorted)

	#size_constraints=int(lines[0][0])
	coe = []
	for i in b0_sortedIndex:
		coeSorted=[lines[i+4][idx] for idx in nonBasicCoeIndex]
		coe.append(coeSorted)
	
	dic_sorted.append(coe)
		#print coeSorted

	#sort the last line in dictionary, which is object function
	objSorted=[lines[-1][0]]
	tmp=[lines[-1][idx+1] for idx in nonBasicCoeIndex]
	objSorted.extend(tmp)
	dic_sorted.append(objSorted)
	#print objSorted

	#print "dic_unsorted:",lines
	#print "dic_sorted:",dic_sorted
	return  dic_sorted